package chain.builder;

/**
 * Builder模式
 *
 * @author: 张从龙
 * time: 2022/12/14 14:26
 */
public class StudentBuilder {

    private final Student student = new Student();

    public StudentBuilder name(String name) {
        student.setName(name);
        return this;
    }

    public StudentBuilder age(int age) {
        student.setAge(age);
        return this;
    }

    public Student create() {
        return student;
    }


    public static void main(String[] args) {
        StudentBuilder mStudentBuilder = new StudentBuilder();
        //测试链式编程
        Student mStudent = mStudentBuilder.name("luyi").age(18).create();

        System.out.println(mStudent.toString());
    }
}